package com.lanswon.qzsmk.controller.cardManageController;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lanswon.qzsmk.base.DwzPage;
import com.lanswon.qzsmk.base.HttpContants;
import com.lanswon.qzsmk.service.systemManageService.BlackListGenManageService;
import com.lanswon.qzsmk.vo.BlackListGenVo;
import com.lanswon.qzsmk.vo.ResultVo;

@Controller
@RequestMapping(value="/blackList")
public class BlackListController  {
	
	@Autowired
	BlackListGenManageService bls;
	
	/**
	 * 链接黑名单管理页面
	 * @return
	 */
	@RequiresPermissions("blackList:index")
	@RequestMapping(value="/index",name="黑名单管理页面,blackList:index",method={RequestMethod.POST,RequestMethod.GET})
	public String goBlackLit(){
		
		return "BlackList";
	}
	
	@RequiresPermissions("blackList:showBlackListGen")
	@SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping(value="/showBlackListGen",name="显示黑名单列表,blackList:showBlackListGen",method=RequestMethod.POST)
	public DwzPage<BlackListGenVo> showBlackListGen(BlackListGenVo bVo,Integer numPerPage,Integer pageNum){
		DwzPage<BlackListGenVo> dPage=null;
//		if(bVo.getNumPerPage()==null){//加载页面时执行
//			bVo.setCurrentPage(1);
//			bVo.setNumPerPage(20);
//		}else {
//			if(bVo.getCurrentPage()<=1||pageCount==0){
//				bVo.setCurrentPage(1);
//			}else if(bVo.getCurrentPage()>=pageCount&&pageCount!=0){
//				bVo.setCurrentPage(pageCount);
//			}
//		}
		if(pageNum==null&&numPerPage==null){
			pageNum=1;
			numPerPage=20;	
		}
		bVo.setCurrentPage(pageNum);
		bVo.setNumPerPage(numPerPage);
		bVo.setStartLine((bVo.getCurrentPage()-1)*bVo.getNumPerPage());
		ResultVo resultVo=bls.showBlackListGen(bVo);
		if(resultVo.getResultStatus().getCode()==HttpContants.RETURN_SUCCESS){
			dPage=(DwzPage<BlackListGenVo>) resultVo.getServiceObject();
		}
		return dPage;
	}
}
